package edu.taru.service.impl;

import edu.taru.aspectj.LogAspectj;
import edu.taru.mapper.UserMapper;
import edu.taru.pojo.User;
import edu.taru.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    //声明sl4j 日志
    private static Logger logger = LoggerFactory.getLogger(LogAspectj.class);

    private UserMapper userMapper;

    @Autowired
    public UserServiceImpl(UserMapper userMapper){
        this.userMapper = userMapper;
    }

    /**
     * 登录
     * @param userName
     * @param userPassword
     * @return
     */
    @Override
    public User getUserByUserNamePassword(String userName, String userPassword) {
        return userMapper.getUserByUserNamePassword(userName,userPassword);
    }

    /**
     * 通过Id查询角色和权限
     * @param userId
     * @return
     */
    @Override
    public User getUserByUserId(String userId) {
        return userMapper.getUserByUserId(userId);
    }


    @Override
    public List<User> seletUser() {
        return userMapper.selectUser();
    }
    /**
     * 查询用户信息
     */
    public User selectUseInfor(Integer uid){
        return userMapper.selectUserInfor(uid);
    }

    @Override
    public int updateUser(User user) {
        return userMapper.updateUser(user);
    }
}
